package com.ethink.platform.controller.system;

import com.ethink.framework.common.web.context.SPRequestContextHolder;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import com.ethink.framework.common.web.BaseController;
import com.ethink.framework.common.web.response.CommonResponse;
import com.ethink.system.api.SystemTodoFacade;
import com.ethink.system.api.info.SystemTodoInfo;
import com.ethink.system.api.request.SystemTodoListPendingRequest;

/**
 * 代办事项表 Controller
 *
 * @author default
 * @date 2022-12-09
 */
@Tag(name = "SystemTodoController", description = "代办事项表 Controller")
@RestController
@Slf4j
@RequestMapping("platform-server/v1/system-service")
public class SystemTodoController extends BaseController {

    @Autowired
    private SystemTodoFacade systemTodoFacade;

    @Operation(summary = "待处理列表查询")
    @GetMapping("/systemTodo/listPending")
    public CommonResponse<List<SystemTodoInfo>> listSystemTodoPending() {
        SystemTodoListPendingRequest request = new SystemTodoListPendingRequest();
        request.setUserCode(SPRequestContextHolder.getCurrentSystemUserLoginName());
        return succeedWith(systemTodoFacade.listSystemTodoPending(request));
    }

    @Operation(summary = "完成")
    @PutMapping("/systemTodo/done/{systemTodoId}")
    public CommonResponse doneSystemTodo(@PathVariable("systemTodoId") Long systemTodoId) {
        systemTodoFacade.doneSystemTodo(systemTodoId);
        return succeed();
    }

}